<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Rails::Initializable::ClassMethods</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" href="../../../css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../css/main.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../css/github.css" type="text/css" media="screen" />
<script src="../../../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../js/main.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>

</head>

<body>     
    <div class="banner">
        
            <span>Ruby on Rails v4.0.0</span><br />
        
        <h1>
            <span class="type">Module</span> 
            Rails::Initializable::ClassMethods 
            
        </h1>
        <ul class="files">
            
            <li><a href="../../../files/railties/lib/rails/initializable_rb.html">railties/lib/rails/initializable.rb</a></li>
            
        </ul>
    </div>
    <div id="bodyContent">
        <div id="content">
  


  


  
  


  


  
    <!-- Method ref -->
    <div class="sectiontitle">Methods</div>
    <dl class="methods">
      
        <dt>I</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="ClassMethods.html#method-i-initializer">initializer</a>,
              </li>
            
              
              <li>
                <a href="ClassMethods.html#method-i-initializers">initializers</a>,
              </li>
            
              
              <li>
                <a href="ClassMethods.html#method-i-initializers_chain">initializers_chain</a>,
              </li>
            
              
              <li>
                <a href="ClassMethods.html#method-i-initializers_for">initializers_for</a>
              </li>
            
          </ul>
        </dd>
      
    </dl>
  

  



  

    

    

    


    


    <!-- Methods -->
        
      <div class="sectiontitle">Instance Public methods</div>
      
        <div class="method">
          <div class="title method-title" id="method-i-initializer">
            
              <b>initializer</b>(name, opts = {}, &amp;blk)
            
            <a href="ClassMethods.html#method-i-initializer" name="method-i-initializer" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-initializer_source')" id="l_method-i-initializer_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/bc7ac33846274a0d2c93741bf6df441d4853e4e9/railties/lib/rails/initializable.rb#L82" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-initializer_source" class="dyn-source">
                <pre><span class="ruby-comment"># File railties/lib/rails/initializable.rb, line 82</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">initializer</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">opts</span> = {}, &amp;<span class="ruby-identifier">blk</span>)
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-string">&quot;A block must be passed when defining an initializer&quot;</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">blk</span>
  <span class="ruby-identifier">opts</span>[<span class="ruby-value">:after</span>] <span class="ruby-operator">||=</span> <span class="ruby-identifier">initializers</span>.<span class="ruby-identifier">last</span>.<span class="ruby-identifier">name</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">initializers</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">initializers</span>.<span class="ruby-identifier">find</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-identifier">i</span>.<span class="ruby-identifier">name</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">opts</span>[<span class="ruby-value">:before</span>] }
  <span class="ruby-identifier">initializers</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">Initializer</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">name</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">opts</span>, &amp;<span class="ruby-identifier">blk</span>)
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-initializers">
            
              <b>initializers</b>()
            
            <a href="ClassMethods.html#method-i-initializers" name="method-i-initializers" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-initializers_source')" id="l_method-i-initializers_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/bc7ac33846274a0d2c93741bf6df441d4853e4e9/railties/lib/rails/initializable.rb#L65" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-initializers_source" class="dyn-source">
                <pre><span class="ruby-comment"># File railties/lib/rails/initializable.rb, line 65</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">initializers</span>
  <span class="ruby-ivar">@initializers</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">Collection</span>.<span class="ruby-identifier">new</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-initializers_chain">
            
              <b>initializers_chain</b>()
            
            <a href="ClassMethods.html#method-i-initializers_chain" name="method-i-initializers_chain" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-initializers_chain_source')" id="l_method-i-initializers_chain_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/bc7ac33846274a0d2c93741bf6df441d4853e4e9/railties/lib/rails/initializable.rb#L69" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-initializers_chain_source" class="dyn-source">
                <pre><span class="ruby-comment"># File railties/lib/rails/initializable.rb, line 69</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">initializers_chain</span>
  <span class="ruby-identifier">initializers</span> = <span class="ruby-constant">Collection</span>.<span class="ruby-identifier">new</span>
  <span class="ruby-identifier">ancestors</span>.<span class="ruby-identifier">reverse_each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">klass</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">next</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:initializers</span>)
    <span class="ruby-identifier">initializers</span> = <span class="ruby-identifier">initializers</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">initializers</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">initializers</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-initializers_for">
            
              <b>initializers_for</b>(binding)
            
            <a href="ClassMethods.html#method-i-initializers_for" name="method-i-initializers_for" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-initializers_for_source')" id="l_method-i-initializers_for_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/bc7ac33846274a0d2c93741bf6df441d4853e4e9/railties/lib/rails/initializable.rb#L78" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-initializers_for_source" class="dyn-source">
                <pre><span class="ruby-comment"># File railties/lib/rails/initializable.rb, line 78</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">initializers_for</span>(<span class="ruby-identifier">binding</span>)
  <span class="ruby-constant">Collection</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">initializers_chain</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-identifier">i</span>.<span class="ruby-identifier">bind</span>(<span class="ruby-identifier">binding</span>) })
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
                    </div>

    </div>
  </body>
</html>    